<?php
include_once('common/header.php');	
if($AppUI->id <= 0 || !isset($_SERVER['HTTP_REFERER'])) {	
	Vfriend_Function::redirect(HOST_VFRIEND);
}
$strRefer		= isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$strToken		= $objRequest->getParam('ptoken','');
$strSession		= isset($_SESSION['cancelationUser' . $AppUI->id]) ? $_SESSION['cancelationUser' . $AppUI->id] : '';
if(Vfriend_Function::isValidLink($strRefer) && $strToken != '' && $strSession != '' && $strSession == $strToken) {
	$objVfriendUser = new Vfriend_User();
	$objVfriendUser->updateStatuses($AppUI->id,2);
	Vfriend_Session::end(0);
	if (isset($_SESSION) && $_SESSION) {
		session_regenerate_id();
		foreach ($_SESSION as $key=>$value) {
			if ($key != SESSION_BACKURL && $key != 'VFRIEND_MESSAGE') {
				unset($_SESSION[$key]);
			}
		}
	}
	if (isset($_COOKIE[COOKIE_VFRIEND_AUTH]) && $_COOKIE[COOKIE_VFRIEND_AUTH] != '') {
		$arrCookieAuth 	= explode('::', Vfriend_Function::base64D($_COOKIE[COOKIE_VFRIEND_AUTH]));
		$strEmail 		= $arrCookieAuth[0];
		$strPassword 	= $arrCookieAuth[1];
		$intLength		= $arrCookieAuth[2];
		$strCookies 	= $strEmail . '::' . $strPassword . '::' . $intLength . '::0';
		Vfriend_Function::setCookie(COOKIE_VFRIEND_AUTH, Vfriend_Function::base64E($strCookies));
	}
	Vfriend_Function::setMsg($arrMessage[26]);
	Vfriend_Function::redirect(HOST_VFRIEND);
} else {
	Vfriend_Function::setError($arrError[34]);
	Vfriend_Function::redirect($strRefer);
}
?>